<%-- 
    Document   : drawreport
    Created on : Oct 12, 2010, 4:03:19 PM
    Author     : user
--%>


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.awt.*" %>
<%@page import="java.io.*" %>
<%@page import="java.sql.*"%>
<%@page import="helper.*"%>
<%@page import="org.jfree.chart.plot.PlotOrientation"%>
<%@page import="org.jfree.data.category.DefaultCategoryDataset"%>
<%@page import="org.jfree.chart.*" %>
<%@page import="org.jfree.chart.entity.*" %>
<%@page import="org.jfree.data.general.*"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
            DefaultCategoryDataset data1 = new DefaultCategoryDataset();
            try
                    {
            Connection con = ConnectionHelper.GetConnection();
            String sql = "Select * from Activities";
            PreparedStatement p = con.prepareStatement(sql);
            ResultSet rs1 = p.executeQuery();
            while(rs1.next())
                    {
                        sql = "Select count(*) from UsersActivities where ActivityID=?";
                        p = con.prepareStatement(sql);
                        p.setInt(1,rs1.getInt("ActivityID"));
                        ResultSet rs2 = p.executeQuery();
                        if(rs2.next())
                            {
                                data1.setValue(rs2.getInt(1),rs1.getString("Title"),rs1.getString("Title"));
                            }
                    }
                    JFreeChart chart1 = ChartFactory.createBarChart3D("Report","Activity","Number Of Member",data1,PlotOrientation.VERTICAL,false,true,false);
                    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
                    final File file1 = new File(getServletContext().getRealPath("/") + "chart1.png");
                    ChartUtilities.saveChartAsPNG(file1, chart1, 600, 400, info);
                    }catch(Exception e)
                            {
                                e.printStackTrace();
                            }
        %>
    </body>
</html>
